package com.zhangyj.component.tags;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.zhangyj.LocalMessage;

public class I18NTag extends AbstractTag {
	Logger log = LoggerFactory.getLogger(I18NTag.class);
	private static final long serialVersionUID = 2104179453963952252L;
	private String key;

	@Override
	public int doStartTag() throws JspException {
		try {
			this.pageContext.getOut().print(LocalMessage.get(key));
			return SKIP_BODY;
		} catch (Exception e) {
			HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
			log.error(request.getServletPath() + ":没有定义国际化(" + key + ")");
		}
		return EVAL_BODY_INCLUDE;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}
}
